var mb = new messagebox();

$(document).ready(function() {
    fixLayoutDocument();

    createNiceScrollBar();

    $('ul.tab-ff').delegate('> li', 'click', function() {
        var $tabFF = $(this).closest('.tab-ff');
        $tabFF.find('> li').not(this).removeClass('actived');
        $(this).addClass('actived');
    });

    $('.toggle-box').delegate('.title', 'click', function() {
        var $box = $(this).closest('.toggle-box');
        var status = $box.hasClass('expanded');
        $box.find('.content').stop(true, true).slideToggle(500).promise().done(function() {
            !status ? $box.addClass('expanded') : $box.removeClass('expanded');
        });

    });

    $('.toggle-box').delegate('ul.itemnav > li', 'click', function() {
        var $itemnav = $('ul.itemnav');
        $itemnav.find('li').removeClass('actived');
        $(this).addClass('actived');
    });

    $('#navManagement .toggle-box').delegate('ul.itemnav > li', 'click', function() {

    });

});

function fixLayoutDocument() {
    setFullLayout();
    $(window).resize(function() {
        setFullLayout();
    });
    function setFullLayout() {
        var hW = $(window).outerHeight();
        hW = hW > 700 ? hW : 700;
        var hH = $('#header').outerHeight();
        $('#document').css({height: hW});
        $('#content').css({height: (hW - hH - 50)});
    }
}


function createNiceScrollBar() {
    $("#contentManagement, #navManagement").niceScroll({
        autohidemode: false,
        cursorcolor: "#869524",
        cursorwidth: 7
    });
}